13/03/2021

About the session

  1. Cholera Outbreak
  2. Formats of spatial data
  3. Transformations
  4. Visualisations
  5. Distances
  6. Real world maps

The 1854 Cholera Outbreak in London

  • Killed hundreds of people in the Soho district
  • Broad Street and its water pump
  • John Snow’s investigation \(\rightarrow\) modern epidemiology
  • Germ-contaminated water versus miasma

John Snow’s original map

Data Format

  • library(cholera) \(\rightarrow\) R Studio Cloud
  • Location of pumps, roads and fatalities

Fatalities

##    case         x         y
## 1     1 13.588010 11.095600
## 2     2  9.878124 12.559180
## 3     3 14.653980 10.180440
## 4     4 15.220570  9.993003
## 5     5 13.162650 12.963190
## 6     6 13.806170  8.889046
## 7     7 13.102140 10.560810
## 8     8 11.004030 11.867130
## 9     9 15.154750 11.704510
## 10   10 11.126390  9.643859

Pumps

##    id                    street         x         y
## 1   1              Market Place  8.651201 17.891600
## 2   2        Adam and Eve Court 10.984780 18.517851
## 3   3            Berners Street 13.378190 17.394541
## 4   4             Newman Street 14.879830 17.809919
## 5   5          Marlborough Mews  8.694768 14.905470
## 6   6 Little Marlborough Street  8.864416 12.753540
## 7   7              Broad Street 12.571360 11.727170
## 8   8            Warwick Street 10.660970  7.428647
## 9   9             Bridle Street 13.521460  7.958250
## 10 10             Rupert Street 16.434891  9.252130
## 11 11               Dean Street 18.914391  9.737819
## 12 12          Tichborne Street 16.005110  5.046838
## 13 13               Vigo Street  8.999440  5.101023

Roads

##       id               name        x1        y1        x2        y2
## 1   44-1 Adam and Eve Court 11.525000 17.075001 10.971961 18.573677
## 2  464-1         Air Street 13.198000  4.573000 12.624683  5.814575
## 3  502-1         Air Street 13.692000  3.513000 13.198000  4.573000
## 4  510-1      Albany Street  9.782852  3.410366  8.783585  5.088188
## 5  516-1   Albemarle Street  4.526501  5.037122  5.650495  3.291797
## 6   52-1       Allens Court 14.159412 17.262054 14.332000 16.490000
## 7   52-2       Allens Court 14.332000 16.490000 14.389000 16.499001
## 8  420-1        Angel Court 15.571000  5.992000 16.221251  6.089315
## 9  355-1      Archer Street 15.527000  7.785000 16.758667  8.698886
## 10 161-1       Argyll Place  7.912320 13.136154  8.896467 13.560133
## 11 172-1       Argyll Place  7.208197 12.739539  7.912320 13.136154
## 12 176-1       Argyll Place  6.758898 12.486461  7.208197 12.739539
## 13 130-1      Argyll Street  7.235000 14.425000  6.796000 15.297000
## 14 130-2      Argyll Street  6.796000 15.297000  6.632517 15.821804
## 15 162-1      Argyll Street  7.912320 13.136154  7.235000 14.425000

Transformations

  • 1 step \(\leftrightarrow\) 100 meters
  • Does not generalise
  • Latitude and longitude more universal

Algorithm for obtaining the latitude and longitude

  1. Find latitude and longitude for Pump 7
  2. Research how longitude and latitude correspond to meters at that location
  3. Calculate the latitude and longitude for other data points by relating them to Pump 7

Transformed pumps data

##                       street         x         y      lat       long
## 1               Market Place  8.651201 17.891600 51.51889 -0.1418470
## 2         Adam and Eve Court 10.984780 18.517851 51.51945 -0.1384855
## 3             Berners Street 13.378190 17.394541 51.51844 -0.1350378
## 4              Newman Street 14.879830 17.809919 51.51882 -0.1328746
## 5           Marlborough Mews  8.694768 14.905470 51.51621 -0.1417842
## 6  Little Marlborough Street  8.864416 12.753540 51.51427 -0.1415399
## 7               Broad Street 12.571360 11.727170 51.51335 -0.1362000
## 8             Warwick Street 10.660970  7.428647 51.50949 -0.1389519
## 9              Bridle Street 13.521460  7.958250 51.50996 -0.1348314
## 10             Rupert Street 16.434891  9.252130 51.51113 -0.1306346
## 11               Dean Street 18.914391  9.737819 51.51156 -0.1270628
## 12          Tichborne Street 16.005110  5.046838 51.50735 -0.1312537
## 13               Vigo Street  8.999440  5.101023 51.50739 -0.1413454

Visualisations

ggplot for visualisations

ggplot()  +
    # Adding layer of roads
    geom_segment(data = roads_plt, 
               aes(x = long1, y = lat1, xend = long2, yend = lat2)) + 
    # Addign layer of fatalities
    geom_point(data = fatal_plt, aes(x = long, y = lat), size = 1.1) +
    # Adding layer of pumps
    geom_point(data = pumps_plt, aes(x = long, y = lat), 
               col = "red4", fill = "red1", pch = 25, size = 3) +
    # Adding labels for pumps
    geom_label(data = pumps_plt, aes(x = long, y = lat, label = lbl), 
               nudge_y = 0.0007) 

Distances

Distance Metrics - Euclidean Distance

\[ \sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2} \]

Distance Metrics - Manhattan Distance

\[ |x_1 - x_2| + |y_1 - y_2| \]

ggplot for grouping and arrows

df222 <- tibble(x = fatal_plt$long[222], y = fatal_plt$lat[222],
                xend = pumps_plt$long[7], yend = pumps_plt$lat[7])

ggplot() + 
  # Colour by closest pump
  geom_point(data = fatal_plt, 
             aes(x = long, y = lat, colour = closest_euclid)) +
  geom_segment(data = roads_plt, 
               aes(x = long1, y = lat1, xend = long2, yend = lat2)) +
  geom_point(data = pumps_plt, aes(x = long, y = lat), 
             col = "red4", fill = "red1", pch = 25, size = 3) +
  # Add arrows with the arrow argument
  geom_segment(data = df222, 
                aes(x = x, y = y, xend = xend, yend = yend),
                arrow = arrow(length = unit(1, "cm")), size = 2)

Is Pump 7 the cause for the outbreak?

## # A tibble: 6 x 5
## # Groups:   pump_id [6]
##   pump_id closest_euclid closest_man euclid_perc man_perc
##   <fct>            <int>       <int>       <dbl>    <dbl>
## 1 0                   52          56        0.09     0.1 
## 2 6                   61          50        0.11     0.09
## 3 7                  358         360        0.62     0.62
## 4 8                   16          20        0.03     0.03
## 5 9                   27          29        0.05     0.05
## 6 10                  64          63        0.11     0.11

Requires further analysis.

Real World Maps

  • the OpenStreetMap library
  • the Mercator projection

Further Resources